home *** CD-ROM | disk | FTP | other *** search
/ X User Tools / X User Tools (O'Reilly and Associates)(1994).ISO / sun4c / archive / tcltk.z / tcltk / slib / tk / demos / mkBasic.tcl < prev    next >
Text File  |  1994-09-20  |  3KB  |  62 lines

  1. # mkBasic w
  2. #
  3. # Create a top-level window that displays a basic text widget.
  4. #
  5. # Arguments:
  6. #    w -    Name to use for new top-level window.
  7.  
  8. proc mkBasic {{w .basic}} {
  9.     catch {destroy $w}
  10.     toplevel $w
  11.     dpos $w
  12.     wm title $w "Text Demonstration - Basic Facilities"
  13.     wm iconname $w "Text Basics"
  14.     button $w.ok -text OK -command "destroy $w"
  15.     text $w.t -relief raised -bd 2 -yscrollcommand "$w.s set" -setgrid true
  16.     scrollbar $w.s -relief flat -command "$w.t yview"
  17.     pack $w.ok -side bottom -fill x
  18.     pack $w.s -side right -fill y
  19.     pack $w.t -expand yes -fill both
  20.     $w.t insert 0.0 {\
  21. This window is a text widget.  It displays one or more lines of text
  22. and allows you to edit the text.  Here is a summary of the things you
  23. can do to a text widget:
  24.  
  25. 1. Scrolling. Use the scrollbar to adjust the view in the text window.
  26.  
  27. 2. Scanning. Press mouse button 2 in the text window and drag up or down.
  28. This will drag the text at high speed to allow you to scan its contents.
  29.  
  30. 3. Insert text. Press mouse button 1 to set the insertion cursor, then
  31. type text.  What you type will be added to the widget.  You can backspace
  32. over what you've typed using either the backspace key, the delete key,
  33. or Control+h.
  34.  
  35. 4. Select. Press mouse button 1 and drag to select a range of characters.
  36. Once you've released the button, you can adjust the selection by pressing
  37. button 1 with the shift key down.  This will reset the end of the
  38. selection nearest the mouse cursor and you can drag that end of the
  39. selection by dragging the mouse before releasing the mouse button.
  40. You can double-click to select whole words, or triple-click to select
  41. whole lines.
  42.  
  43. 5. Delete. To delete text, select the characters you'd like to delete
  44. and type Control+d.
  45.  
  46. 6. Copy the selection. To copy the selection either from this window
  47. or from any other window or application, select what you want, click
  48. button 1 to set the insertion cursor, then type Control+v to copy the
  49. selection to the point of the insertion cursor.
  50.  
  51. 7. Resize the window.  This widget has been configured with the "setGrid"
  52. option on, so that if you resize the window it will always resize to an
  53. even number of characters high and wide.  Also, if you make the window
  54. narrow you can see that long lines automatically wrap around onto
  55. additional lines so that all the information is always visible.
  56.  
  57. When you're finished with this demonstration, press the "OK" button
  58. below.}
  59.     $w.t mark set insert 0.0
  60.     bind $w <Any-Enter> "focus $w.t"
  61. }
  62.